<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home_model extends MY_Model {

	/* ABOUT US*/
	function get_abouts(){
		$this->db->select('*');
		$this->db->where('status',1);
		$this->db->where('parent_id',4);
		$this->db->order_by('order_view','ASC');
		$query = $this->db->get(PREFIX.'news');
		if($query->num_rows() > 0)
		{
			return $query->result();
		}
		return false;
	}

	/**** POLL FUNCTION ***/
	function get_poll(){
		$this->db->select('*');
		$this->db->where('status',1);
		$this->db->order_by('order_view','DESC');
		$query = $this->db->get(PREFIX.'polls');
		if($query->num_rows() > 0)
		{
			$result = $query->result();
			return $result[0];
		}
		return false;
	}

	function get_poll_answer($poll_id = 0){
		if($poll_id > 0){
			$this->db->select('*');
			$this->db->where('status',1);
			$this->db->where('poll_id',$poll_id);
			$this->db->order_by('order_view','ASC');
			$query = $this->db->get(PREFIX.'polls_answer');
			if($query->num_rows() > 0)
			{
				return $query->result();
			}
			return false;
		}
		return false;
	}

	function getNews($parent_id){
		$this->db->select('*');
		$this->db->where('status',1);
		$this->db->where('parent_id',$parent_id);
		$this->db->limit(5);
		$this->db->order_by('order_view','ASC');
		$query = $this->db->get(PREFIX.'news');
		if($query->num_rows() > 0)
		{
			return $query->result();
		}
		return false;
	}
}
?>
